home *** CD-ROM | disk | FTP | other *** search
- DXF2HSH
- DXF polyline/polygon to DXF 3D Face converter
- by Vance Gloster May 1994
- based on
- DXF2TRI
- DXF polyline/polygon to triangle converter
- by Tim Riley Aug 1993
- based on
- POLY2TRI - a polygon to triangle converter
- by Steve Anger Jan 1993
-
- This program is commited to the public domain. Feel free to use all or part
- of this code in your own programs. If you simply MUST show gratitude, send
- Animation Master .seg and .fig files for something cool you've created or a
- favorite bitmapped texture to my internet email address, vance@netcom.com.
-
- This is a utility that extracts polyline shapes from a DXF file and breaks
- them down into individual triangles. The polylines are assumed to be closed,
- planar (2D) polygons. This program only deals with POLYLINE entities and
- ignores all other entities in the DXF file. All properties (color, line type)
- are ignored.
-
- The input DXF file consists of one or more polylines with no more than 2000
- vertices. This limit is rather arbitrary and can be changed if necessary by
- changing POLYMAX.
-
- The program uses the following syntax:
-
- DXF2HSH infile[.DXF] outfile[.DXF] [xy]
-
- The xy switch when added at the end modifies the plane that it extracts the
- polygons from. The software I use, 3d Font, ouputs DXF files in the XZ plane
- as do some other programs. My understanding is that Corel Draw 4.0 outputs
- DXF files in the XY plane, so this switch should be used if you are exporting
- drawings from Corel. Using the wrong setting on this switch usually results
- in the object that you import being just a line with a bunch of control points
- on it.
-
- The output file is a DXF file which consists of 3D Face objects, one for each
- triangle.
-
- So what is the program good for? The program I use to do 3D rendering is
- Animation Master from Hash, Inc.who also make Playmation. They have included
- a limited utility for importing DXF files. This was designed to be used with
- DXF files created by a company (whose name I have forgotten) that makes high
- quality models of almost anything and sells them for more money than I can
- afford. These models consist of triangles expressed as 3D Face objects.
- Since the import utility was only designed to read this format, it does not
- read DXF files that have the more common POLYLINE objects.
-
- What *I* wanted to do was to import text using fancy fonts. I found a Windows
- program called 3D Font by a company called Visual Software which will accept
- text and output a DXF file using any TrueType font. Unfortunately, these DXF
- files consist of POLYLINE objects. To make a long story short (too late) my
- program converts the output of 3D Font into a format that you can import into
- Animation Master.
-
- The code to read the POLYLINE DXF file and break it into triangles was in the
- program I derived this program from. I merely modified the POLYLINE reader
- to use either the y or the z as the second dimension of the POLYLINE construct
- which 3D Font uses for some reason. I added the code to output the 3D Face
- objects. To figure out what was required I merely created a couple of triangles
- in the Sculpture module of Animation Master and output them as a DXF file and
- emulated the form, assuming that whatever it could output it should be able to
- input. I was fortunate in finding a program that had most of the pieces I needed
- already done. Thanks, Tim! Thanks Steve!
-
- This archive should contain the following:
-
- DXF2HSH.C The source
- DXF2HSH.EXE The executable, compiled with Microsoft Visual
- C++ 1.5, medium memory model. No extenders,
- no memory tricks, so you don't have to worry about
- EMM386 and it's ilk and it runs fine from within
- Windows.
- DXF2HSH.MAK Visual C++ make file.
- DXF2HSH.DOC This file.
- V.DXF The output of 3D Font of a capital V in Times New
- Roman font.
- VH.DXF V.DXF converted by DXF2HSH.
- V.SEG VH.DXF imported into the Sculpture module of Animation
- Master.
-
- Here are the steps for using DXF2HSH with 3D Font and Animation Master.
- A similar process should be possible with most Windows drawing programs
- like Corel, Micrographix Designer, Adobe's drawing program, etc.
-
- 1. Use 3D Font to generate a DXF file of your text. If you are using
- some other package, make sure that you convert all curves to line
- segments (POLYLINES). 3D Font does this automatically. In 3D Font
- use the "Save 2d..." option to create the file. In any other
- package, make sure it creates a 2D DXF file, not a 3D DXF file.
- Assume for the purposes of this example that you have created a DXF
- file called MYTEXT.DXF. My test was performed with version 2.0 of
- 3D Font.
-
- 2. Run the DXF2HSH utility. For our example the command string is:
-
- DXF2HSH MYTEXT AMTEXT
-
- 3. Run the Sculpture module of Animation Master. Under the File menu
- select "Import DXF...". Select AMTEXT.DXF in the dialog box that
- comes up. You will see your text appear. Make sure that you
- have version 2.04 or later of Sculpture (the version number is in
- the About box) because previous versions had a bug in DXF import.
-
- 4. For best results, at this point select "Select All" from the Group
- menu, and then Peak Grouped Points. You can do this by either
- typing 'K' or pressing the button with the icon that looks like
- this:
- .
- ./ \.
-
- with stright lines. This makes the triangles operate the way they
- are supposed to with straight lines.
-
- 5. Since the imported object is only 2D, you will probably want to
- extrude it. Since there are often LOTS of control points (because
- these are triangles), this operation may be very sluggish. Be
- patient, if you wait long enough I have found that eventually
- Animation Master does what it is supposed to.
-
- 6. Since the objects created this way have lots of control points they
- tend to render a little slower. I have had some luck simplifying
- the models by removing control points and extra lines. Simple
- fonts like Arial are not too bad. The complex fonts like Chili
- Pepper contain an amazing number of points. Try doing this first
- with Arial before you get extreme.
-
- Below are the directions that came with the program I derived DXF2HSH from.
- They may help people with using Corel, but the predecessor program was
- designed to create a format used by POV, a public domain raytracer. I
- have experimented a lot with the tools I have and have not encountered
- the problems he tries to solve in step 2 below. I have imported both 'O'
- and '&' without any difficulties. He talks about an extrude function which
- is disabled in my program because Animation Master's extrude feature is
- more useful. The code for extruding is still included in the source if
- you are an ambitions C programmer and need this feature.
-
- If you have problems with a particular DXF file, I make no promises about
- fixing it or providing support. Your best shot is to create the SIMPLEST
- DXF file that exhibits the problem, and email it to me at my internet
- address vance@netcom.com along with a BRIEF description of the problem. I
- will fix it if I have time. Good luck!
-
- -Vance Gloster
- May 15, 1994
-
- (Documentation for DXF2TRI)
- To keep things straight forward, here is how I put text in a scene (NOTE:
- I am assuming a reasonable knowledge of CorelDraw. This method should be
- possible with other Windows draw (NOT paint) programs such as Micrographix,
- Adobe Draw (Designer?) and others, none of which I have any experience with,
- assuming they have the following capabilities:
- * can export a DXF file
- * converts curves to line segments (POLYLINES)
- otherwise, you're out of luck):
-
- 1. Use Corel (4.0) to generate the initial text. Overall size and
- position is not important since you will scale and position it later
- on. Line properties (type, thickness or color) are irrelevant since
- they will be ignored, as well as fill properties.
-
- 2. Dealing with holes: re-entrant (concave) portions of a letter appear
- to convert with no problems (the m and & of the test image seem to
- prove this). Holes are another matter. In the simplest view, they are
- another object/curve. Since the objects will be converted to 2D
- triangles, CSG cannot be used to subtract them from the main object.
- The easiest solution I have found is to make all holes part of the
- main object's outline. This is accomplished in two steps:
- a. Convert the letter from text to a curve. Do this after you
- have done all of the transformations you care to do on your
- text. You cannot convert from curves back to text (well you
- can, in a way, but font creation is beyond to scope of this
- babble).
- b. Using the node edit tool, cut a channel of zero width between
- the hole and the outside of the curve/letter. This can be done
- anywhere. As long as the sides of the channel touch, there will
- be no visible effect on the finished product. For example:
- Turn: into:
- *** ***
- *** *** *** ***
- ** ** ** **
- ** *** ** ** *** **
- * ** ** * * ** ** *
- * ** ** * * ** ** *
- * * * * * * * *
- * * * * * * * *
- * * * * * * * *
- * ** ** * * ** ** *
- * ** ** * * ** ** *
- ** *** ** ** * * **
- ** ** ** * * **
- *** *** **** ****
- *** * *
- These segements overlap --->| |<---
-
- If you want to be artistic, you can cut the channels in
- obvious places, where a curve intersects a straight segment,
- for example. I broke the ampersand in the following places:
-
- ***
- * *
- * *
- * \
- \*
- * * *
- * *
- * * *
- * * *
-
- and then removed the unnecessary nodes on the straight line
- segments. This has the added effect of reducing the number of
- vertices of the polyline, as well as the number of triangles
- and the complexity of the final object.
-
- 3. Export the text as a DXF file. The Corel 4.0 DXF filter converts all
- curves to line segments. It allows you to choose the number of line
- segments a curve is converted to. I chose 32 (the minimum value) to
- minimize the complexity of the object. There is no visible degradation
- to the object when rendered at 1024x768 (and, I suspect, greater).
- Individual letters may be exported to separate DXF files if you want
- to texture them separately. The COREL-DXF-RAW-POV conversion chain
- retains the relative position of each letter, but they become separate
- objects and inter-letter spacing becomes a problem unless you first
- combine them as a composite in the scene file before performing any
- transformation. If you are going to texture the text uniformly, it
- is easier to export the text to a single DXF file and treat it as a
- single object.
-
- 4. Run DXF2TRI on the DXF file to generate a RAW file. If you want to
- extrude the letters, use the -e switch. If the back of the letters will
- be visible (due to reflections or camera position), use the -b switch
- to generate solid backs to the letters.
-
- 5. Run RAW2POV on the RAW file. RAW2POV will generate a POV file giving
- the physical limits of the object(s) and an INC file consisting of
- triangles, smooth triangles and bounding shapes. The rest is up to you.
-
- No, its not overly easy or straight forward, but it works well and the results
- aren't bad. Before anyone has a chance to ask or comment, no it won't bevel,
- but I am thinking of it. A straight bevel should be possible, but a curved
- (routed) bevel will take some doing, since CSG won't work with triangles. Don't
- let me stop anyone else from working on the problem, since I have a lot of
- other things to keep me busy.
-
- I assume NO responsibility for this program or its effects, but if you need to
- contact me, for whatever reason, I check in occasionally to The Graphics
- Alternative and my Internet address is: triley@its.bldrdoc.gov.
-
- Doo dah.